Welcome to the third step of our final project.
And in the last video we rebuilt marriage passport folio and at first glance the past performance looks
pretty terrific here.
However in the past marriage has not closely monitored the performance of our portfolio and based on
the impressive result over the total twenty two years period.
She may be overestimates the performance and in a very first meeting she is set for investment periods
of six years or longer.
I never lost money with my portfolio and the question is here is she right and this is actually the
perfect application case for a return triangle.
We have still imparted our healthcare index and in a next step we change the frequency of our healthcare
index from daily to annual frequency.
And of course we can do the service of the every sample method and we have here and yellow and the for
each and every period for each and every year we want to have the very last.
Trading Prize and by running the sale here we would get a panda series and we can also convert the panda
series to a data frame with the method to frame.
And finally we save the data frame and the available annual so that's at the annual Values for our new
index starting with 100 at the end of nineteen hundred ninety six and over eight hundred here.
And so the column label as health care here and we can change the column label to for example price.
So that's more meaningful here.
And then we add another column called return.
And here we calculate the lock return or the annual lock return of our prices.
And of course we can do this here with the number pi method and Peter lock and we divide each price
by the immediately preceding price of the preceding year.
So let's do this here and then we actually drop the very first row where we have an A values in the
return column and several up here.
So here we have the prices and uh the lock returns.
Starting from nineteen hundred ninety seven and two thousand and eighteen.
And that sum total twenty two years or twenty two periods and we can also determine this uh with uh
the index attribute and then getting the size of our index and we say actually 22 and the variable years
and then the next step we create a list starting with 22 until 1 and we assign the variable windows.
So this is here a list comprehension.
And then finally we create the 22 new columns uh for our annual data frame.
And these columns are actually rolling statistics.
So we have the rolling mean return for Windows starting from twenty two years until only one year and
we can do this here with a for loop and we iterate over the windows list starting with 22.
So we're creating first of all the column with the column label twenty two years.
And here we calculate the rolling mean return with a window of twenty two years.
And that's what we exactly doing for all elements in the windows list.
So let's run the sale here and let's have a look again at our annual data frame.
So still we a fair price and a return as columns and we have a year rolling mean returns twenty two
years until a one year and finally we dropped the columns the price and return and we save for the new
data frame and the rabbit triangle
and now we are finally prepared to plot our return triangle.
And we can do this with a seaborne heat map and we pass our triangle data frame to S.A. that heat map.
And it's always a bit tricky to determine.
We men we max and center but with returns that always make sense to our faith center of 0 percent.
So no positive or negative return.
And we sat here we max to 15 percent.
So we have deep green fourth that's where we have never it's return of 15 percent or more.
And we determined we mean as being minus 10 percent.
So let's create here the plot
so that's the return triangle for our customized index.
And we can see here that is only very little red.
So here we have said during the dot com crisis some reds and also he and the financial crisis.
But the overall performance of our index remains pretty terrific here.
So a lot of green here.
And the final question is do we find any a period with six years or longer that the average return is
negative or in other words do we find any investment period of six years or longer where Mary lost money
with her portfolio.
And obviously if you go here to nine years then we can see an average return of minus 0.01 percent.
And it's actually no surprise that this is the nine year period from 2001 to 2009 including uh the dot
com bubble and also the financial crisis.
But as a summary we can say that Mary was not right and she kind of well estimated the performance of
our portfolio and with this we are finishing with part three and we will continue in part for us.
So hope to see there by.